package Covid3;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class CovidBean2 implements WritableComparable<CovidBean2> {

    Long infect;
    Long death;

    public CovidBean2() {
    }

    public CovidBean2(Long infect, Long death) {
        this.infect = infect;
        this.death = death;
    }

    public Long getInfect() {
        return infect;
    }

    public void setInfect(Long infect) {
        this.infect = infect;
    }

    public Long getDeath() {
        return death;
    }

    public void setDeath(Long death) {
        this.death = death;
    }


    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(infect);
        dataOutput.writeLong(death);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {

        infect = dataInput.readLong();
        death = dataInput.readLong();
    }

    @Override
    public String toString() {
        return infect+"\t"+death;
    }

    @Override
    public int compareTo(CovidBean2 o) {
        if (this.infect<o.infect)
        {
            return 1;
        }
        else if (this.infect==o.infect)
        {
            return 0;
        }
        else
        {
            return -1;
        }
    }
}
